package tests;

import common.Utils;
import org.openqa.selenium.By;

public class ListPage extends Utils {
    public static String url = "http://8.137.19.140:9090/blog_list.html";
    public ListPage() {
        super(url);
    }

    public void checkBlogList()
    {
        //检查博客标题
        String titleText = driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(1) > div.title")).getText();
        //检查博客时间
        String timeText = driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(1) > div.date")).getText();
        //检查博客内容
        String contentText = driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(1) > div.desc")).getText();
        //检查查看全文按钮
        String actualText = driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(1) > a")).getText();

        String expectText = "查看全文>>";
        //校验查看全文按钮
        assert actualText.equals(expectText);
        //校验标题、博客内容、时间不能为空
        assert !titleText.isEmpty();
        assert !timeText.isEmpty();
        assert !contentText.isEmpty();


        driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(1) > a")).click();

    }
}
